<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<style type="text/css">
	.list-dot-othors li{width: 16%;}
</style>
<?php 
    $sname_self_flag = true;#检测当前source_name是否在系统的来源名称库里
    $ssname_all = array();#所有的来源名称
    if($source_name){//如果当前source_name不为空则进行判断
        foreach($this->setting as $v){
            $ssname_all[]=$v['source_name'];
        }
        if (in_array($source_name, $ssname_all)){
            $sname_self_flag=false;
        }
        unset($ssname_all);
    }
?>
<script language="javascript">
<!--
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
		$("#title").formValidator({onshow:"请输入标题",onfocus:"请输入标题",oncorrect:"正确"}).inputValidator({min:1,onerror:"请输入标题"});
	})
//-->
function ValidateValue(textbox) {
	var IllegalString = "[`~!#$^&*()=|{}':;'\\[].<>/?~#";
	var textboxvalue = textbox.value;
	var index = textboxvalue.length - 1;
	 
	var s = textbox.value.charAt(index);
	 
	if (IllegalString.indexOf(s) > 0) {
		alert('非法字符：'+s);
		s = textboxvalue.substring(0, index);
		textbox.value = s;
		return false;
	}
}

$(function(){
	$('#s_sname').change(function(){
		var source_name = $(this).val();
	    if(source_name=="yes"){  
	        $('#self_sname').css('display','block');
	        $('#self_sname').focus();
	    }else if(source_name=="no"){ 
	        //alert('no');
	        $('#self_sname').css('display','none');
	    } 
	})
})
</script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>content_addtop_new.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>colorpicker.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH?>swfupload/swf2ckeditor.js"></script>
<h3 style="padding-left: 20px;padding-top: 10px">
<a href="javascript:history.back(-1);" style="font-size:14px;color: #0000FF"><em>返回上一级</em></a>
</h3>
<form action="?m=<?php echo ROUTE_M;?>&c=<?php echo ROUTE_C;?>&a=<?php echo ROUTE_A;?>&rid=<?=$id?>" method="post" name="myform" id="myform">
<input type="hidden" name="source_type" value="2" />
<input type="hidden" name="talent_id" value="<?php echo $_GET['talent_id'];?>" />
<input type="hidden" name="talent_type" value="<?php echo $_GET['talent_type'];?>" />
<input type="hidden" name="menuid" value="<?php echo $_GET['menuid'];?>" />
<div class="pad-10">
		<div class="col-tab">
			<div id="div_setting_1" class="contentList pad-10">
<table cellpadding="2" cellspacing="1" class="table_form" width="100%">
	<tr>
		<th width="100"><?php echo L('title')?> :</th>
		<td>
			<input name="manage[title]" id="title" class="input-text" value="<?=$title?>" type="text" size="40" onkeyup="ValidateValue(this)" >
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('keywords')?> :</th>
		<td>
			<input name="manage[keywords]" id="keywords" class="input-text" value="<?=$keywords?>" type="text" size="40" onkeyup="ValidateValue(this)" >
			<span style="color: red;font-size:18px;"><strong>注意：</strong>多关键字之间用英文","隔开</span>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('type')?> :</th>
		<td>
			<select name="manage[type_id]" >
				<option value="0">请选择</option>
				<?php echo $types;?>
			</select>
		</td>
	</tr>
	<tr>
		<th width="200"><?php echo L('information_cate')?>：</th>
		<td>
			<a href="javascript:;" onclick="omnipotent('selectid','?m=content&c=content&a=add_cates&siteid=<?php echo $this->siteid;?>&source_id=<?php echo $id;?>&source_type=2','<?php echo L('choose_cate')?>',1);return false;" style="color:#B5BFBB">[<?php echo '新增栏目绑定';?>]</a><ul class="list-dot-othors" id="add_othors_text"><?=$cates?> </ul>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('contestName')?> :</th>
		<td>
			<select name="contestid" >
				<option value="0">请选择</option>
				<?php echo $categorys;?>
			</select>
		</td>
	</tr>
	<tr>
		<th width="200"><?php echo L('source_name')?>：</th>
		<td><select name="manage[source_name]" id="source_name">
			<option value="" selected="">请选择</option>
			<?php foreach($this->setting as $v){?>
			<option value="<?php echo $v['source_name'];?>" <?php if ($v['source_name'] == $source_name){?> selected <?php }?>><?php echo $v['source_name'];?></option>
			<?php }?>
			</select>
			<?php echo form::select(array('2'=>'外部采集', '1'=>'站内添加'), $source, 'name="manage[source]"')?>
								&nbsp;&nbsp;是否编辑<b>来源名称</b>：<select name='manage[sname_manual_flag]' id='s_sname'>
								    <option value='no'>否</option>
								    <option value='yes'<?php if ($sname_self_flag) {
								        echo 'selected';
								    }?>>是</option>
								</select>&nbsp;<span style='color:red;font-weight:bold;'>来源名称如需手动输入，请选择"是"；默认为"否"！</span><br><input style='display:<?php echo $sname_self_flag?'block':'none'?>;' type='text' name='manage[sname_manual]' id='self_sname' placeholder='请在此输入要编辑的来源名称...' value='<?=$source_name?>' size=30>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('source_link')?> :</th>
		<td>
			<input name="manage[source_link]" class="input-text" value="<?=$source_link?>" id="source_link" type="text" size="40">
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('source_author')?> :</th>
		<td>
			<input name="manage[source_author]" class="input-text" value="<?=$source_author?>" type="text" size="40">
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('video_link')?> :</th>
		<td>
			<!-- <input name="manage[video_link]" id="video_link" class="input-text" value="<?=$video_link?>" type="text" size="40"> -->
			<?php echo form::upfiles('manage[video_link]', 'video_link', $video_link, '', '', 40, '', '', 'mp4|avi')?>
		</td>
	</tr>
	<tr>
		<th width="100"><?php echo L('video_time')?> :</th>
		<td><input name="manage[video_time]" id="video_time" class="input-text" value="<?=$video_time?>" type="text" size="40"></td>
	</tr>
	<tr>
		<th width="100"><?php echo L('image_cover')?> :</th>
		<td><?php echo form::images_crop('manage[image_cover]', 'image_cover', $image_cover)?></td>
	</tr>
	<tr>
		<th width="100">竖行图 :</th>
		<td><?php echo form::images_crop('manage[image_vertical]', 'image_vertical', $image_vertical)?></td>
	</tr>
	<tr>
		<th><?php echo L('description')?> :</th>
		<td><textarea name="manage[description]" id="description" cols="60"rows="6"><?=$description?></textarea>
		<?php echo form::editor('description','full','','','',1,1)?></td>
	</tr>

<tr>
		<th></th>
		<td><input name="dosubmit" type="submit"  id="dosubmit"  value="<?php echo L('submit')?>" ></td>
	</tr>

</table>
</div>
</div>
</div>
</form>
</body>
</html>
<script language="javascript" type="text/javascript">
function AdsType(adstype) {
	$('#SizeFormat').css('display', 'none');
	if(adstype=='0') {
		
	} else if(adstype=='1') {
		$('#SizeFormat').css('display', '');
	}
}
$('#AlignBox').click( function (){
	if($('#AlignBox').attr('checked')) {
		$('#PaddingLeft').attr('disabled', true);
		$('#PaddingTop').attr('disabled', true);
	} else {
		$('#PaddingLeft').attr('disabled', false);
		$('#PaddingTop').attr('disabled', false);
	}
}); 
</script>

<script language="javascript">
	$(function(){
		$('#source_name').change(function(){
			var source_name = $(this).val();
			if (!source_name) {
				$('#source_link').attr('value','');$('#source_link').attr('readonly', false);return false;
			}
			$.ajax({
				type:"get",
				url:"?m=picture&c=picture&a=ajaxSourceLink&pc_hash=<?php echo $_SESSION['pc_hash'];?>&source_name="+source_name,
				dataType: "json",
				success:function(data){
					if(data['status']){
						$('#source_link').attr('value',data['source_link']);
						$('#source_link').attr('readonly', true);
					}
				}
			})
		})
	})
</script>